/*
 * KDMUserTrackingAction.cpp
 *
 *  Created on: Jul 8, 2011
 *      Author: blyth
 */

#include <KDMSteppingAction.hh>
#include <KDMTrackingInfo.hh>
#include <KDMGlobals.hh>
#include <G4String.hh>
#include <G4Track.hh>
#include <G4SteppingManager.hh>
#include <iostream>
using namespace std;

KDMSteppingAction::KDMSteppingAction() {
	;
}

KDMSteppingAction::~KDMSteppingAction() {
	;
}

void KDMSteppingAction::UserSteppingAction(const G4Step*) {
	G4Track* track = fpSteppingManager->GetfTrack();
	G4String volName = track->GetVolume()->GetName();
	if (!volName.contains("space")) {
		KDMTrackingInfo* info = (KDMTrackingInfo*) track->GetUserInformation();
		if (info) {
			G4String nextVolName = track->GetNextVolume()->GetName();
			if (nextVolName.contains("Crystal")) {
				/*				G4String particleName = track->GetParticleDefinition()->GetParticleName();
				 if (info->originatedFromCV()) {
				 if (particleName.contains("gamma")) {
				 double energy = track->GetKineticEnergy();
				 photonEnergyDist->Fill(energy / MeV);
				 }
				 }*/
				track->SetTrackStatus(fStopAndKill);
			}
		}
	}

	//	if (volName.contains("Veto")) {
	//		if (/*track->GetParticleDefinition()->GetPDGCharge() != 0*/false)
	//			CV = true;
	//	}
}
